package edu.qust.y22.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.qust.y22.bean.Admin;
import edu.qust.y22.bean.AdminExample;
import edu.qust.y22.mapper.AdminMapper;
import edu.qust.y22.service.AdminService;

//声明该层为Service服务
@Service
public class AdminServiceImpl implements AdminService{
	
	//声明其AdminMapper
	@Autowired
	private AdminMapper adminMapper;
	
	//重写父类方法
	@Override
	public Admin selectByUserName(String userName) {
		
		AdminExample be = new AdminExample();
		AdminExample.Criteria c = be.createCriteria();
		c.andUserNameEqualTo(userName);
		
		List<Admin> admins = this.adminMapper.selectByExample(be);
		if(admins != null && admins.size() > 0) {
			return admins.get(0);
		}
		return null;
	}
	
	//添加新用户
	@Override
	public int insert(Admin bean) {
		return this.adminMapper.insert(bean);
	}
	

}
